package com.airline.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.airline.beans.Customer;
import com.airline.connection.AirlineSystemServiceProxy;
import com.airline.form.DeleteCustomerIDForm;


public class DeleteCustomerIDAction extends DispatchAction{
	AirlineSystemServiceProxy proxy = new AirlineSystemServiceProxy();
	
	public ActionForward deleteId(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		
		String custid = request.getParameter("custid");
		
		
		
		Customer cust = proxy.getCustomer(custid);

		if (null == cust) {

		((DeleteCustomerIDForm)	(form)).setError("No Customer with the ID " + custid + " exists");
			return mapping.findForward("failure");
		}

		

		boolean res = proxy.deleteCustomer(custid);
		if(res == false){
	
		}
			
		return mapping.findForward("success");
		
	}
		
}
